package com.huawei.appgallery.appcomment.ui;

import android.content.Context;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager.OnPageChangeListener;
import com.huawei.appgallery.appcomment.api.UserCommentListActivityProtocol;
import com.huawei.appgallery.appcomment.api.UserCommentListActivityProtocol.Request;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.ui.framework.activity.BaseActivity;
import com.huawei.appgallery.foundation.ui.framework.uikit.ContractFragment;
import com.huawei.appgallery.foundation.ui.framework.widget.FixViewPager;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import huawei.widget.HwSubTabWidget;
import huawei.widget.HwSubTabWidget.b;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;
import o.bcb;
import o.bcg;
import o.bcg.d;
import o.bcg.h;
import o.ben;
import o.cdk;
import o.cdz;
import o.cia;
import o.ciy;
import o.FragmentManager;
import o.FragmentTransaction;
import o.kc;

public class UserCommentListActivity extends BaseActivity<UserCommentListActivityProtocol> implements b, com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.BaseListFragment.c {
    private HwSubTabWidget ˋॱ;
    private Map<Integer, Object> ͺ = new HashMap();
    private FixViewPager ॱˊ;

    class c extends kc {
        final /* synthetic */ UserCommentListActivity ˋ;
        Fragment ॱ;

        public c(UserCommentListActivity userCommentListActivity, FragmentManager juVar) {
            this.ˋ = userCommentListActivity;
            super(juVar);
        }

        public Fragment ˏ(int i) {
            Fragment ॱ;
            switch (i) {
                case 1:
                    ॱ = this.ˋ.ʼॱ();
                    break;
                default:
                    ॱ = this.ˋ.ᐝॱ();
                    break;
            }
            bcb.ˋ.ˋ("UserCommentActivity", "getItem, position:" + i + ", Fragment:" + ॱ);
            if (ॱ == null) {
                return new ContractFragment();
            }
            return ॱ;
        }

        public void setPrimaryItem(ViewGroup viewGroup, int i, Object obj) {
            super.setPrimaryItem(viewGroup, i, obj);
            Fragment fragment = (Fragment) obj;
            if (fragment != this.ॱ) {
                this.ॱ = fragment;
            }
        }

        public int getCount() {
            return this.ˋ.ˋॱ.ॱ();
        }

        public Fragment ॱ() {
            return this.ॱ;
        }
    }

    static class e implements OnPageChangeListener {
        private WeakReference<HwSubTabWidget> ˋ;

        public e(HwSubTabWidget hwSubTabWidget) {
            this.ˋ = new WeakReference(hwSubTabWidget);
        }

        public void onPageScrolled(int i, float f, int i2) {
            if (this.ˋ != null) {
                HwSubTabWidget hwSubTabWidget = (HwSubTabWidget) this.ˋ.get();
                if (hwSubTabWidget != null) {
                    hwSubTabWidget.setSubTabScrollingOffsets(i, f);
                }
            }
        }

        public void onPageScrollStateChanged(int i) {
            if (this.ˋ != null) {
                HwSubTabWidget hwSubTabWidget = (HwSubTabWidget) this.ˋ.get();
                if (hwSubTabWidget != null) {
                    hwSubTabWidget.setSubTabSelected(i);
                }
            }
        }

        public void onPageScrolled(int i) {
        }
    }

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        if (getActionBar() != null) {
            getActionBar().hide();
        }
        setContentView(d.ʻॱ);
        getWindow().getDecorView().setBackgroundColor(getResources().getColor(bcg.a.ॱ));
        Object ab_ = ab_();
        if (ab_ instanceof HashMap) {
            this.ͺ = (HashMap) ab_;
        }
        ᐝ();
    }

    private void ᐝ() {
        ॱ(getString(h.ॱㆍ));
        ͺ();
        ॱˊ();
    }

    private void ͺ() {
        this.ˋॱ = (HwSubTabWidget) findViewById(o.bcg.e.ꓸॱ);
        String[] strArr = new String[]{getResources().getString(h.ॱㆍ), getString(h.ˎͺ)};
        int length = strArr.length;
        for (int i = 0; i < length; i++) {
            boolean z;
            ben o_ben = new ben(strArr[i], String.valueOf(i));
            HwSubTabWidget hwSubTabWidget = this.ˋॱ;
            hwSubTabWidget.getClass();
            HwSubTabWidget.a aVar = new HwSubTabWidget.a(hwSubTabWidget, o_ben.ˋ(), this);
            aVar.ˎ(i);
            hwSubTabWidget = this.ˋॱ;
            if (i == 0) {
                z = true;
            } else {
                z = false;
            }
            hwSubTabWidget.ॱ(aVar, z);
        }
    }

    private void ॱˊ() {
        this.ॱˊ = (FixViewPager) findViewById(o.bcg.e.ʾᐝ);
        this.ॱˊ.setAdapter(new c(this, ˏॱ()));
        this.ॱˊ.addOnPageChangeListener(new e(this.ˋॱ));
        this.ॱˊ.setOffscreenPageLimit(1);
        this.ॱˊ.setCurrentItem(0);
    }

    private Fragment ᐝॱ() {
        String ˊ;
        Request ˎ = ʾ() == null ? null : ((UserCommentListActivityProtocol) ʾ()).ˎ();
        if (ˎ != null) {
            ˊ = ˎ.ˊ();
        } else {
            ˊ = null;
        }
        return MyCommentListFragment.ॱ(ˊ);
    }

    private Fragment ʼॱ() {
        String ˊ;
        Request ˎ = ʾ() == null ? null : ((UserCommentListActivityProtocol) ʾ()).ˎ();
        if (ˎ != null) {
            ˊ = ˎ.ˊ();
        } else {
            ˊ = null;
        }
        return UserReplyListFragment.ˎ(ˊ);
    }

    public void onDestroy() {
        super.onDestroy();
    }

    public Object T_() {
        return this.ͺ;
    }

    public cia ॱ(int i) {
        Object obj = this.ͺ.get(Integer.valueOf(i));
        if (obj instanceof cia) {
            return (cia) obj;
        }
        return null;
    }

    public void ˋ(int i, cia o_cia) {
        if (o_cia != null) {
            this.ͺ.put(Integer.valueOf(i), o_cia);
        }
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (16908332 != menuItem.getItemId()) {
            return super.onOptionsItemSelected(menuItem);
        }
        finish();
        return true;
    }

    public void ˊ(HwSubTabWidget.a aVar, FragmentTransaction kaVar) {
        if (this.ॱˊ != null) {
            c cVar = (c) this.ॱˊ.getAdapter();
            if (cVar != null) {
                Fragment ॱ = cVar.ॱ();
                if (ॱ != null && (ॱ instanceof ciy)) {
                    ((ciy) ॱ).ʾॱ();
                }
            }
        }
    }

    public void ˎ(HwSubTabWidget.a aVar, FragmentTransaction kaVar) {
        if (this.ˋॱ != null) {
            int ˊ = this.ˋॱ.ˊ();
            if (ˊ == 1) {
                String ˎ = cdz.ˎ();
                String userId = UserSession.getInstance().getUserId();
                int i = h.ॱꜟ;
                cdk.ॱ(this, cdk.ˏ((Context) this, i), "04|" + userId + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + ˎ);
            }
            if (this.ॱˊ != null) {
                this.ॱˊ.setCurrentItem(ˊ);
            }
        }
    }

    public void ॱ(HwSubTabWidget.a aVar, FragmentTransaction kaVar) {
    }
}
